package com.wanxi.test;

import java.util.ArrayList;

public class FilterStudent {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList();
        list.add(new Student("张三1", 22));
        list.add(new Student("1张三2", 14));
        list.add(new Student("张三3", 17));
        list.add(new Student("1张三4", 33));
        list.add(new Student("张三5", 10));
        list.add(new Student("1张三6", 25));
        ArrayList<Student> aa = aa(list);
        System.out.println(aa);
    }

    public static ArrayList<Student> aa(ArrayList<Student> list) {
        ArrayList<Student> arrayList = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
//            if (list.get(i).getAge() < 18) {
//                arrayList.add(list.get(i));
//            }
            if(list.get(i).getName().startsWith("张三")){
                arrayList.add(list.get(i));
            }
        }
        return arrayList;
    }
}
